package ch.hearc.infrarouge.tests;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import ch.hearc.infrarouge.preferences.Preferences;

public class TestSQLite {

	public static void main(String[] args) throws ClassNotFoundException {
		Class.forName("org.sqlite.JDBC");

		Connection connection = null;
		try {
			connection = DriverManager
					.getConnection(Preferences.connectionString);

			Statement statement = connection.createStatement();

			String tableName = "user";
			String query = "SELECT * FROM " + tableName;
			ResultSet resultSet = statement.executeQuery(query);

			while (resultSet.next()) {
				String name = resultSet.getString("name");
				System.out.println(name);
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			if (connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}

	}
}
